home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / 2.asm < prev    next >
Encoding:
Assembly Source File  |  1999-07-15  |  8.1 KB  |  320 lines

  1. .386
  2. .MODEL    FLAT, STDCALL
  3.  
  4. UNICODE=0
  5. include w32.inc
  6.  
  7. WinMain PROTO         :HINSTANCE,:HINSTANCE,:LPSTR,:SDWORD
  8. DrawIcon PROTO         :DWORD,:DWORD,:DWORD,:DWORD
  9. wsprintfA PROTO C     :PROC
  10. extrn BeginPaint     :PROC
  11. extrn EndPaint         :PROC
  12. extrn lstrcat         :PROC
  13. extrn GetSystemDirectoryA:PROC
  14.  
  15. .data
  16. DlgName             db "MainWindow",0
  17. ChildName         db "AboutChild",0
  18. FontName         db "script",0
  19. YourSerial         db "File to be patched:",0
  20. filename1         db "CZ-VBcrackMe.exe",0
  21.  
  22. ErrorNotFound         db "Couldn't find the file, make sure it is in the specified path and not in use...",0
  23. ErrorPatched         db "File is already patched, or it is a different version!",0
  24. Error             db "Error occured",0
  25. Succeeded         db "Completed",0
  26. ErrorWriteFailure     db "Write Failure",0
  27. Instructions         db "Nag killed... Now register using '55555' as code!",0
  28.  
  29. about             db 0Ah,0Dh,"Fully 32b Patcher by Duelist.",0Ah,0Dh,0Ah,0Dh,"This Patcher was coded using TASM",0Ah,0Dh,0Ah,0Dh,"and LCC Resource Editor.",0Ah,0Dh,0Ah,0Dh,"Visit iNSiDE on EFNet at #iNSiDE99!",0
  30.  
  31. IconHandle          dd ?
  32. BitmapHandle          dd ?
  33. hInstance          HINSTANCE ?
  34. CommandLine         LPSTR ?
  35. filehandle         dd 0
  36. bytesread         dd 0
  37. readbuffer         db 200 dup(?)
  38. originalb         db 0FFh,096h,0BCh,001h,000h,000h
  39. newb             db 090h,090h,090h,090h,090h,090h
  40.  
  41. hDcMem              dd ?
  42. hfont              dd ?
  43. lprect             RECT <>
  44. DlgRect           RECT <>            
  45. locebp24          dd 0
  46. DlgWidth           dd ?
  47. DlgHeight           dd ?
  48. DesktopRect           RECT <>
  49.  
  50. IDC_OK               equ 1
  51. IDC_GENERATE         equ 101
  52. IDC_ABOUT         equ 102
  53. IDC_EXIT          equ 103
  54. IDC_SERIAL         equ 105
  55. ID_ABOUTTEXT         equ 201
  56. IDI_ICON               equ 115
  57. IDI_BITMAP             equ 116
  58. ICON_SMALL         equ 0
  59. DEFAULT_PITCH        equ 0
  60. DEFAULT_QUALITY         equ 0
  61. OEM_CHARSET           equ 255
  62. CLIP_CHARACTER_PRECIS    equ 1
  63. CLIP_DEFAULT_PRECIS      equ 0
  64. OUT_DEFAULT_PRECIS       equ 0
  65.  
  66.  
  67. .code
  68. start:
  69.     call GetModuleHandle, NULL
  70.     mov  hInstance,eax
  71.     call GetCommandLine
  72.         call WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
  73.     call ExitProcess,eax
  74. WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:SDWORD
  75.         mov  eax, OFFSET DlgProc
  76.         call DialogBoxParam, hInst, offset DlgName,NULL,eax,NULL
  77.         ret
  78. WinMain endp
  79.  
  80. MyProc proc
  81.     call CreateFileA, offset filename1, GENERIC_READ OR GENERIC_WRITE, NULL, NULL, OPEN_EXISTING, NULL, NULL
  82.     cmp eax, INVALID_HANDLE_VALUE
  83.     jne a1
  84.     call MessageBoxA, 0, offset ErrorNotFound, offset Error, MB_OK
  85.     ret
  86.     a1:
  87.     mov dword ptr [filehandle], eax
  88.     call SetFilePointer, filehandle, 004D48h, NULL, NULL
  89.     call ReadFile, filehandle, offset readbuffer, 6, offset bytesread, NULL
  90.     mov ebx, 5
  91.     c1:
  92.     movsx eax, byte ptr [originalb+ebx]
  93.     cmp byte ptr [readbuffer+ebx], al
  94.     jne b1
  95.     dec ebx
  96.     cmp ebx, -1
  97.     jne c1
  98.     call SetFilePointer, filehandle, 004D48h, NULL, NULL
  99.     call WriteFile, filehandle, offset newb, 6, offset bytesread, NULL
  100.     cmp eax, 0
  101.     je e1
  102.  
  103.     aa1:
  104.  
  105.     call SetFilePointer, filehandle, 004D86h, NULL, NULL
  106.     call WriteFile, filehandle, offset newb, 6, offset bytesread, NULL
  107.     cmp eax, 0
  108.     jne d1
  109.  
  110.     e1:
  111.     call MessageBoxA, 0, offset ErrorWriteFailure, offset Error, MB_OK
  112.     ret
  113.     d1:
  114.     call MessageBoxA, 0, offset Instructions, offset Succeeded, MB_OK
  115.     mov eax, 99h
  116.     ret
  117.     b1:
  118.     call MessageBoxA, 0, offset ErrorPatched, offset Error, MB_OK
  119.     ret
  120. MyProc endp
  121.  
  122. DlgProc proc Handle: HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
  123.         LOCAL hdc:HDC
  124.         LOCAL ps:PAINTSTRUCT
  125.         LOCAL rect:RECT
  126.     mov  eax, uMsg
  127.     cmp  eax, WM_CTLCOLORDLG
  128.     je   create_brush
  129.     cmp  eax, WM_PAINT
  130.     je   write_labels
  131.         cmp  eax, WM_DESTROY
  132.     jne  next
  133.         call PostQuitMessage, NULL
  134.         xor eax, eax    
  135.     next:    
  136.     cmp eax, WM_INITDIALOG
  137.     jne fourth
  138.         call SetDlgItemTextA, Handle, IDC_SERIAL, offset filename1
  139.     call LoadIconA, hInstance, IDI_ICON
  140.         mov IconHandle, eax
  141.     call LoadBitmap, hInstance, IDI_BITMAP
  142.     mov BitmapHandle, eax
  143.         call GetDlgItem, Handle, IDC_EXIT
  144.         call SetFocus,eax
  145.         call SendMessage, Handle, WM_SETICON, ICON_SMALL, IconHandle
  146.     push offset DlgRect
  147.        push Handle
  148.     call GetWindowRect
  149.        call GetDesktopWindow
  150.     push offset DesktopRect
  151.     push eax
  152.     call GetWindowRect
  153.     push 0
  154.     mov eax,DlgRect.rc_bottom
  155.     sub eax,DlgRect.rc_top
  156.     mov DlgHeight,eax
  157.     push eax
  158.     mov eax,DlgRect.rc_right
  159.     sub eax,DlgRect.rc_left
  160.     mov DlgWidth,eax
  161.     push eax
  162.     mov eax, DesktopRect.rc_bottom
  163.     sub eax, DlgHeight
  164.     shr eax, 1
  165.     push eax
  166.     mov eax, DesktopRect.rc_right
  167.     sub eax, DlgWidth
  168.     shr eax, 1
  169.     push eax
  170.     push Handle
  171.     call MoveWindow
  172.     fourth:
  173.     cmp eax, WM_CLOSE
  174.     jne fifth
  175.         call EndDialog, Handle, NULL
  176.     fifth:
  177.         cmp eax, WM_COMMAND
  178.     jne msg_done
  179.         mov eax, wParam
  180.         cmp ax, IDC_EXIT
  181.     jne is_it_about
  182.     shr eax, 16
  183.     cmp ax, BN_CLICKED
  184.     jne msg_done
  185.         
  186.     call MyProc
  187.         cmp eax, 99h
  188.         jne aaa
  189.     call GetDlgItem, Handle, IDC_EXIT
  190.         call EnableWindow, eax, 0
  191.         aaa:
  192.         call CloseHandle, filehandle
  193.         mov filehandle, NULL
  194.  
  195.     jmp msg_done
  196.     is_it_about:
  197.     cmp ax, IDC_ABOUT
  198.     jne msg_done
  199.     shr eax, 16
  200.     cmp ax, BN_CLICKED
  201.     jne msg_done
  202.     call DialogBoxParam, hInstance, offset ChildName, Handle, offset ChildProc, NULL
  203.     jmp msg_done
  204.     create_brush:
  205.         call CreateSolidBrush, 00000000h
  206.     mov eax, 1
  207.         ret
  208.     write_labels:
  209.     lea eax, ps
  210.     push eax
  211.     push [Handle]
  212.     call BeginPaint
  213.         mov hdc,eax
  214.         call CreateCompatibleDC, hdc
  215.         mov hDcMem, eax
  216.      call SelectObject, hDcMem, BitmapHandle
  217.     call BitBlt, hdc, 0, 0, 442, 284, hDcMem, 0, 0, SRCCOPY OR BLACKNESS
  218.         call ReleaseDC, Handle, hdc
  219.         call DeleteDC, hDcMem
  220.       call CreateFont,15,0,0,0,400,0,0,0, OEM_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, offset FontName 
  221.         call SelectObject, hdc, eax
  222.         mov hfont, eax
  223.         call SetTextColor,hdc, 00ffffffh
  224.         call SetBkColor,hdc,00000000h
  225.         call lstrlen, offset YourSerial
  226.         call TextOut,hdc, 24, 162, offset YourSerial, eax
  227.     lea eax, ps
  228.     call EndPaint, Handle, eax                     
  229.     msg_done:
  230.         xor eax, eax
  231.     ret
  232. DlgProc endp
  233.  
  234.  
  235. ChildProc proc Handle:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
  236.         LOCAL hdc:HDC
  237.         LOCAL ps:PAINTSTRUCT
  238.         LOCAL rect:RECT
  239.     mov eax, uMsg
  240.         cmp eax, WM_DESTROY
  241.     je destroy_window
  242.         cmp eax, WM_CLOSE
  243.     jne create_abt_brush
  244.     destroy_window:
  245.         call EndDialog, Handle, NULL
  246.         xor eax, eax
  247.     ret
  248.     create_abt_brush:
  249.     cmp eax, WM_CTLCOLORDLG
  250.     jne do_the_painting
  251.     call CreateSolidBrush, 00000000h
  252.         ret
  253.     do_the_painting:
  254.         cmp eax, WM_PAINT
  255.     jne init_about
  256.     lea eax, ps
  257.     call BeginPaint, Handle, eax
  258.         mov  hdc,eax
  259.         call CreateFont,15,0,0,0,400,0,0,0, OEM_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, offset FontName 
  260.         call SelectObject, hdc, eax
  261.         mov hfont,eax
  262.         call SetTextColor,hdc, 00ffffffh
  263.         call SetBkColor,hdc,00000000h
  264.         call GetClientRect, Handle, offset lprect
  265.         call DrawText, hdc, offset about, -1, offset lprect, DT_CENTER
  266.     lea eax, ps
  267.     call EndPaint, Handle, eax
  268.     jmp about_done
  269.         init_about:
  270.     cmp eax, WM_INITDIALOG
  271.     jne about_command
  272.         call SetFocus, Handle
  273.     push offset DlgRect
  274.        push Handle
  275.     call GetWindowRect
  276.        call GetDesktopWindow
  277.     push offset DesktopRect
  278.     push eax
  279.     call GetWindowRect
  280.     push 0
  281.     mov eax,DlgRect.rc_bottom
  282.     sub eax,DlgRect.rc_top
  283.     mov DlgHeight,eax
  284.     push eax
  285.     mov eax,DlgRect.rc_right
  286.     sub eax,DlgRect.rc_left
  287.     mov DlgWidth,eax
  288.     push eax
  289.     mov eax, DesktopRect.rc_bottom
  290.     sub eax, DlgHeight
  291.     shr eax, 1
  292.     push eax
  293.     mov eax, DesktopRect.rc_right
  294.     sub eax, DlgWidth
  295.     shr eax, 1
  296.     push eax
  297.     push Handle
  298.     call MoveWindow
  299.     mov eax, FALSE
  300.     ret
  301.     about_command:
  302.     cmp eax, WM_COMMAND
  303.     jne about_done
  304.         mov eax, wParam
  305.     cmp lParam, 1
  306.     je about_done
  307.         cmp ax, IDC_ABOUT
  308.     jne about_done
  309.         shr eax,16
  310.     cmp ax, BN_CLICKED
  311.     jne about_done
  312.     call EndDialog, Handle,NULL
  313.     mov eax,FALSE
  314.         ret    
  315.     about_done:
  316.         xor eax, eax
  317.     ret
  318. ChildProc endp
  319.  
  320. end start